
import 'package:flutter/material.dart';

import '../../entity/profile/fans_list_entity.dart';
import '../../network/base_entity.dart';
import '../../network/http_manager.dart';
import '../../ui/widgets/custom_refresh_mixin.dart';
import '../../utils/hud_util.dart';

class FansViewModel extends ChangeNotifier with CustomRefreshMixin {

  void follow(BuildContext context) {
    debugPrint("follow-------");
  }

  void unfollow(BuildContext context) {
    debugPrint("unfollow-------");
  }

  @override
  Future<List> requestList(int page) async {
    List tempL = [];
    Map<String, dynamic> params = {};
    params["size"] = 10;
    params["current"] = page;
    HudUtil.show();
    IBaseEntity? result = await HttpManager.getInstance().request(url: "/api/app/user/fansList", params: params);
    HudUtil.dismiss();
    if (result?.isSuccess() == true) {
      FansListEntity listResult = FansListEntity.fromJson(result?.getData());
      List<FansEntity>? temps = listResult.list;
      if (temps != null) {
        tempL.addAll(temps);
      }
      hasNext = listResult.hasNext ?? false;
    } else {
      HudUtil.toast(result?.getMsg() ?? "");
    }
    return tempL;
  }

  @override
  void onRequestComplete() {
    notifyListeners();
  }
}